var express = require('express');
var path = require('path');
var favicon = require('static-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var session = require('express-session');
var bodyParser = require('body-parser');
var http = require('http');

var setting = require('./setting');
var index = require('./routes/index');
var user = require('./routes/user');
var feedback = require('./routes/feedback');
var message = require('./routes/message');
var event = require('./routes/event');
var newperson = require('./routes/newperson');
var jobs = require('./routes/jobs');
var news = require('./routes/news');
var group = require('./routes/group');
var groupmessage = require('./routes/groupmessage');
var course = require('./routes/course');
var filter = require('./filter');

var app = express();
app.set('port', 3000);
app.use(favicon());
app.use(logger('dev'));
app.use(bodyParser.json({
    limit: '200mb'
}));
app.use(bodyParser.urlencoded({
    limit: '200mb',
    extended: true
}));

app.use(cookieParser("test"));
app.use("/", filter);
app.use("/", index);

app.use(express.static(path.join(__dirname, '../ec_w/web/')));

app.use("/user", user);
app.use("/feedback", feedback);
app.use("/message", message);
app.use("/event", event);
app.use("/newperson", newperson);
app.use("/jobs", jobs);
app.use("/news", news);
app.use("/course", course);
app.use("/group",group);
app.use("/groupmessage",groupmessage);
/// catch 404 and forwarding to error handler

app.listen(app.get("port"), function() {
    console.log(app.get("port"));
});